package auth

import (
	"5title_gin/internal/api/middleware"
	"5title_gin/internal/api/v1/auth"
	"5title_gin/internal/model/user"

	"github.com/gin-gonic/gin"
)

func AuthRouter(privateAPI *gin.RouterGroup, publicAPI *gin.RouterGroup) {
	app := auth.NewUserAPI()

	// 私有路由组
	authAPI := privateAPI.Group("/auth")
	{
		authAPI.POST("/logout", app.LogoutView)
		authAPI.PUT("/password", middleware.BindJsonMiddleware[user.Password], app.EditPwd)
	}

	// 公开路由组
	publicAuthAPI := publicAPI.Group("/auth")
	{
		publicAuthAPI.POST("/login", middleware.BindJsonMiddleware[user.LoginRequest], app.LoginView)
		publicAuthAPI.POST("/refreshToken", middleware.BindJsonMiddleware[user.RefreshTokenRequest], app.RefreshToken)
	}
}
